<%@page import="org.apache.commons.collections.functors.IfClosure"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="domain.entities.interfaces.*"%>
<%@ page import="domain.dao.interfaces.*"%>
<%@ page import="java.util.List"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Show details</title>
<link rel="stylesheet" type="text/css" href="/mdoc-project/css/bootstrap_Boris.css">
<base href="<%=request.getScheme()%>://<%=request.getServerName()%>:<%=request.getServerPort()%><%=request.getContextPath()%>/">
</head>
<body>

	<%
		boolean connected = session
				.getAttribute(DomainUtils.CURRENT_USER_STRING) != null;

		ApplicationContext context = util.SpringUtils
				.getApplicationContext();
		IDAOContactGroup daoContactGroup = (IDAOContactGroup) context
				.getBean("beanDAOContactGroup");

		String strIdContactGroup = request
				.getParameter("selected_contactgroup");
		int idContactGroup = Integer.parseInt(strIdContactGroup);
		IContactGroup cg = daoContactGroup.getById(idContactGroup);

		
		if (connected == false) {
			request.setAttribute(DomainUtils.ALERT_ERROR_STRING,
					"You must be connected");
		}
		else if (cg == null) {
			request.setAttribute(DomainUtils.ALERT_ERROR_STRING,
					"This contact group has been deleted.");
		}
	%>

	<%@include file="/pages/common_style/header.jsp"%>
	<%@include file="/pages/common_style/alerts.jsp"%>

	<div class="panel panel-default">
		<div class="panel-heading"></div>

		<table class="table">
			<thead>
				<tr>
					<th>Information</th>
					<th>Value</th>
				</tr>
			</thead>
			<tbody>
				<%
					if (connected && cg != null) {
				%>
				<tr>
					<td>Group name</td>
					<td><%=cg.getGroupName()%></td>
				</tr>
				<tr>
					<td>Members</td>
					<td>
						<div class="form-control" style="overflow: scroll; height: 150px;">
							<ul>
								<%
									for (IContact c : cg.getContacts()) {
								%>
								<li><%=DomainUtils.displayContact(c)%></li>
								<%
									}
								%>
							</ul>
						</div>
					</td>
					<%
						}
					%>
				
			</tbody>
		</table>
	</div>

	<%
		if(connected) {
	%>
	<br>
	<a class="btn btn-default navbar-btn" href="pages/showAllContactGroups.jsp">Return</a>
	<%
		}
	%>

	<%@include file="/pages/common_style/footer.jsp"%>

</body>
</html>